<?php
class Dmf_Form_Element_Widget extends Dmf_Form_Element
{
    private $_widget;
    
    private $_data = array();
    
    public function __construct( $widget_name )
    {
        $widget = ucfirst( $widget_name . 'Widget' );
        
        $this->_widget = new $widget( $widget_name );
    }
    
    public function setData( $data )
    {
        $this->_data = $data;
    }
    
    public function getContent()
    {
        $this->_widget->setAttributes( array_merge( array(
            'value' => $this->getAttr( 'value' )
        ), $this->_attributes ) );
        $this->_widget->setData( $this->_data );
        
        ob_start();
        
        $this->_widget->render();
        
        return @ob_get_clean();
    }
}